package com.xbongbong.rule.symbol;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.rule.symbol.base.AbstractSymbol;
import com.xbongbong.saas.constant.StringConstant;

/**
 * @author zheng.li
 **/
public class NoLikeSymbol extends AbstractSymbol {

    @Override
    public boolean operation() {
        if (StringUtil.isEmpty(value.toString())) {
            return true;
        }
        if (attr.contains(FieldTypeEnum.SUB_FORM.getEsalias()) && attr.contains(StringConstant.POINT)) {
            //子表单
            JSONArray arrayValue = factJson.getJSONArray(attr);
            return arrayValue.stream().noneMatch(v -> v.toString().contains(conditionValue.toString()));
        }
        return !value.toString().contains(conditionValue.toString());
    }

}
